<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">

	<div class="container-div ui-layout-center">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="upload-form">
					<div class="select-list">
						<ul>
							<li>
								上传人工号：<input type="text" name="importUserid"/>
							</li>
							<li>
								上传文件名：<input type="text" name="fileName"/>
							</li>
							<li class="select-time">
								<label>上传时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-success  btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-success  btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
	        	<a class="btn btn-success" onclick="upload()" shiro:hasPermission="worktime:upload:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
	<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
	<script th:inline="javascript">
		var downFlag = [[${@permission.hasPermi('worktime:upload:download')}]];
		var datas = [[${@dict.getType('input_record_status')}]];
		var prefix = ctx + "worktime/upload";

		$(function() {
			$('body').layout({ west__size: 185 });
			queryRecordList();
		});

		function queryRecordList() {
		    var options = {
		        url: prefix + "/list",
		        createUrl: prefix + "/add",
		        downloadUrl: prefix + "/download",
		        sortName: "uploadTime",
		        sortOrder: "desc",
		        modalName: "数据录入",
		        search: false,
		        showExport: false,
		        columns: [{
		            checkbox: false
		        },
		        {
		            field: 'importId',
		            title: '记录ID',
		            visible: false
		        },
		        {
		            field: 'importUserid',
		            title: '上传人工号',
		            sortable: true
		        },
		        {
		            field: 'userName',
		            title: '上传用户名'
		        },
		        {
		            field: 'uploadTime',
		            title: '上传时间',
		            sortable: true
		        },
		        {
		            field: 'fileName',
		            title: '上传文件名'
		        },
		        {
		            field: 'parseStatus',
		            title: '状态',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, value);
		            }
		        },
		        {
		        	field: 'errorPath',
		            title: '错误信息',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs ' + downFlag + '" href="#" onclick="$.operate.download(\'' + row.importId + '\')"><i class="fa fa-edit"></i>下载</a> ');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		}
		function upload(){
			var url='/worktime/upload/add';

            var	width = 800;
            var height = ($(window).height() - 50);
            layer.open({
            		type: 2,
            		area: [width + 'px', height + 'px'],
            		fix: false,
            		//不固定
            		maxmin: true,
            		shade: 0.3,
            		title: "添加考勤数据",
            		content: url,
            		btn: ['确定'],
            	    // 弹层外区域关闭
            		shadeClose: true,
            		yes: function(index, layero) {
            	        var iframeWin = layero.find('iframe')[0];
            	        iframeWin.contentWindow.submitHandler();
            	    },
            	    cancel: function(index) {
            	        return true;
            	    }
            });
		}
	</script>
</body>
</html>